<?php
namespace application\system\model\auth;
/**
 * Description of Model
 *
 * Model 	: role
 * Created	: 02Oct2014
 * Purpose 	: Role Model
 *
 * Change Logs
 * -----------------------------------------------------------
 * 02Oct2014 admin: Created the model role
 *  
 * @author admin
 *
 * Properties
 * @property String $title Title
 * @property String $type Type
 * @property String $description Description
 */
class Role extends \simbola\core\application\AppModel{
    static  //config params
            $table_name, 
            $primary_key, 
            $class_name, 
            //state machine
            $state_config,
            //relationships
            $has_many = array(), 
            $belongs_to = array(), 
            //alias
            $alias_attribute = array(),
            //validations system
            $validates_uneditable = array(),
            //validations php-ar 
            $validates_presence_of = array(),
            $validates_size_of = array(),
            $validates_length_of = array(),
            $validates_exclusion_of = array(),
            $validates_inclusion_of = array(),
            $validates_format_of = array(),
            $validates_numericality_of = array(),
            $validates_uniqueness_of = array();

    public static function initialize() {
        //Model Setup
        self::setClass(__CLASS__);
        self::setSource('system', 'auth', 'role');
        self::primaryKey(array('title'));        

        //Relationships - Has Many
        self::hasMany(array('assigns', 'class_name' => '\application\system\model\auth\RoleAssign', 'foreign_key' => 'role_title', 'primary_key' => 'title'));
        self::hasMany(array('children', 'class_name' => '\application\system\model\auth\RoleHierarchy', 'foreign_key' => 'child_role_title', 'primary_key' => 'title'));
        self::hasMany(array('parents', 'class_name' => '\application\system\model\auth\RoleHierarchy', 'foreign_key' => 'parent_role_title', 'primary_key' => 'title'));

        //Relationships - Belongs To
        //None

        //Validations
        // - title
        self::validateSizeOf(array("title", "maximum" => 100));
        // - type
        self::validateSizeOf(array("type", "maximum" => 20));
        // - description
    }
}

?>
